package com.wirelesspienetwork.overview.misc;

import ohos.agp.animation.Animator;
import ohos.agp.utils.Rect;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.app.Context;

public class OverviewConfiguration {

    /** Interpolators */
    public int fastOutSlowInInterpolator;
    public int quintOutInterpolator;
    public int linearOutSlowInInterpolator;

    /** Insets */
    public Rect displayRect = new Rect();

    /** Task stack */
    public int taskStackTopPaddingPx;
    public float taskStackWidthPaddingPct;
    public int taskStackScrollDuration;
    public float taskStackOverscrollPct;

    /** Task view animation and styles */
    public int taskViewEnterFromHomeDuration;
    public int taskViewEnterFromHomeDelay;
    public int taskViewEnterFromHomeStaggerDelay;
    public int taskViewTranslationZMinPx;
    public int taskViewTranslationZMaxPx;

    public OverviewConfiguration(Context context) {
        fastOutSlowInInterpolator = Animator.CurveType.ACCELERATE_DECELERATE;
        quintOutInterpolator = Animator.CurveType.DECELERATE;
        linearOutSlowInInterpolator = Animator.CurveType.ACCELERATE_DECELERATE;
        update(context);
    }

    /** Updates the state, given the specified context
     * @param context
     * */
    void update(Context context) {
        DisplayAttributes displayAttributes = DisplayManager.getInstance().getDefaultDisplay(context).get().getAttributes();
        displayRect.set(0,0,displayAttributes.width,displayAttributes.height);

        taskStackTopPaddingPx = 48;
        taskStackWidthPaddingPct = 0.04444f;
        taskStackScrollDuration = 225;
        taskStackOverscrollPct = 0.0875f;
        taskViewEnterFromHomeDuration = 250;
        taskViewEnterFromHomeDelay = 150;
        taskViewEnterFromHomeStaggerDelay = 12;
        taskViewTranslationZMinPx = 20;
        taskViewTranslationZMaxPx = 80;
    }

    /**
     * Returns the task stack bounds in the current orientation. These bounds do not account for
     * the system insets.
     * @param taskStackBounds
     * @param windowHeight
     * @param windowWidth
     */
    public void getOverviewStackBounds(int windowWidth, int windowHeight,
                                       Rect taskStackBounds) {
        taskStackBounds.set(0, 64, windowWidth, windowHeight);
    }
}
